/**
 * Created By zhangQ 2018/2/16
 * 场站相关
 */
import axiosUtils from '@api/env/axiosEnv'

let customAxios = axiosUtils._initAxios()

export function getOwnFleet () {
  return customAxios({
    url: '/main/station/getOwnFleetList',
    method: 'post'
  })
}

export function getOwnFleetWithPage (param) {
  return customAxios({
    url: '/main/station/getOwnFleetListWithPage',
    method: 'post',
    data: param
  })
}

export function getOwnFleetDriverListWithPage (param) {
  return customAxios({
    url: '/main/station/getOwnFleetDriverListWithPage',
    method: 'post',
    data: param
  })
}

export function getOwnFleetTruckListWithPage (param) {
  return customAxios({
    url: '/main/station/getOwnFleetTruckListWithPage',
    method: 'post',
    data: param
  })
}

export function getSysFleet () {
  return customAxios({
    url: '/main/station/getSystemFleetList',
    method: 'post'
  })
}

export function bindFleet (param) {
  return customAxios({
    url: '/main/station/bindFleet',
    method: 'post',
    data: {
      loginName: param.loginName
    }
  })
}

export function bindReceiverFleet (param) {
  return customAxios({
    url: '/main/station/bindReceiverFleet',
    method: 'post',
    data: param
  })
}

export function getReceiverList (param) {
  return customAxios({
    url: '/main/station/getReceiverList',
    method: 'post'
  })
}

export function getReceiverListWithPage (param) {
  return customAxios({
    url: '/main/station/getReceiverListWithPage',
    method: 'post',
    data: param
  })
}

export function deleteReceiver (id) {
  return customAxios({
    url: '/main/station/deleteReceiver',
    method: 'post',
    data: {
      id: id
    }
  })
}

export function relieveFleet (loginName) {
  return customAxios({
    url: '/main/station/relieveFleet',
    method: 'post',
    data: {
      loginName
    }
  })
}

export function assignmentOrder (param) {
  console.log(param)
  return customAxios({
    url: '/main/station/assignment',
    method: 'post',
    data: {
      mainOrderNo: param.mainOrderNo,
      paraPositionTime: param.paraPositionTime
    }
  })
}

export function getTrackList () {
  return customAxios({
    url: '/main/station/getParaPositionTrackList',
    method: 'post'
  })
}

export function getAddressList () {
  return customAxios({
    url: '/main/station/getAddressList',
    method: 'post'
  })
}

export function sendNotice (param) {
  return customAxios({
    url: '/main/station/sendNotice',
    method: 'post',
    data: param
  })
}

export function getStationMember () {
  return customAxios({
    url: '/main/station/getStationMember',
    method: 'post'
  })
}

export function updateStationMember (param) {
  return customAxios({
    url: '/main/station/updateStationMember',
    method: 'post',
    data: {
      surplusSpace: param.surplusSpace,
      surplusArea: param.surplusArea,
      userName: param.userName,
      mobile: param.mobile
    }
  })
}

export function getStationMemberList (param) {
  return customAxios({
    url: '/getStationMemberList',
    method: 'post',
    data: {
      railwayBureauCode: param.railwayBureauCode,
      transportCenter: param.transportCenter,
      stationCode: param.stationCode,
      keysOfNull: 'railwayBureauCode, transportCenter, stationCode'
    }
  })
}

// 通过主订单查询列车所在股道
export function getTrackCodeByMainOrderNo (param) {
  return customAxios({
    url: '/main/station/getTrackCodeByMainOrderNo',
    method: 'post',
    data: {
      mainOrderNo: param.mainOrderNo
    }
  })
}

// 门卫查询是否反箱绑定的子订单
export function getIsBindingSubOrderList (param) {
  return customAxios({
    url: '/main/station/getIsBindingSubOrderList2',
    method: 'post',
    data: param
  })
}

// 门卫确认车辆出场
export function updateSunOrderGuardSubmit (param) {
  return customAxios({
    url: '/main/station/updateSunOrderGuardSubmit2',
    method: 'post',
    data: param
  })
}

// 今日箱情
export function getContainerInfo (param) {
  if (!param.startTime) {
    delete param.startTime
  }
  if (!param.endTime) {
    delete param.endTime
  }
  return customAxios({
    url: '/main/station/getContainerInfo',
    method: 'post',
    data: param
  })
}

// 获得箱情信息
export function getInfoForNotLoadContain (param) {
  if (!param.startTime) {
    delete param.startTime
  }
  if (!param.endTime) {
    delete param.endTime
  }
  return customAxios({
    url: '/main/station/getInfoForNotLoadContain',
    method: 'post',
    data: param
  })
}

/**
 * 通过当前用户查询所有子运单
 * @param param
 * @returns {*}
 */
export function findBySubOrderToUserByPage (param) {
  if (!param.startTime) {
    delete param.startTime
  }
  if (!param.endTime) {
    delete param.endTime
  }
  return customAxios({
    url: '/main/order/findBySubOrderToUserByPage',
    method: 'post',
    data: param
  })
}

/**
 * 通过当前用户查询所有子运单
 * @param param
 * @returns {*}
 */
export function setCoalNo (param) {
  return customAxios({
    url: '/main/order/setCoalNo',
    method: 'post',
    data: param
  })
}

export function getRetentionContainerList (param) {
  return customAxios({
    url: '/main/station/getRetentionContainerList',
    method: 'post',
    data: param
  })
}

/**
 * 提交提煤单类型
 * @param param
 * @returns {*}
 */
export function saveCoalBillType (param) {
  return customAxios({
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    url: '/main/station/saveCoalBillType',
    method: 'post',
    data: param
  })
}

/**
 * 空箱回送整列列表
 * @param param
 * @returns {*}
 */
export function getRailwayEmptyOrderList (param) {
  return customAxios({
    url: '/main/railwayEmptyOrder/getRailwayEmptyOrderList',
    method: 'post',
    data: param
  })
}

/**
 * 空箱回送单列详情列表
 * @param param
 * @returns {*}
 */
export function getRailwayEmptyOrderListByOrderNo (param) {
  return customAxios({
    url: '/main/railwayEmptyOrder/getRailwayEmptyOrderListByOrderNo',
    method: 'post',
    data: param
  })
}

/**
 * 获取车辆类型
 * @param param
 * @returns {*}
 */

export function getTruckType (param) {
  return customAxios({
    url: '/main/fleet/getTruckType',
    method: 'post',
    data: param
  })
}

/**
 * 获取已派单组
 * @param param
 * @returns {*}
 */

export function getSubOrderListByGroupId (param) {
  return customAxios({
    url: '/main/station/getSubOrderListByGroupId',
    method: 'post',
    data: param
  })
}

//  查询自动派单
export function getAutoDispatcher () {
  return customAxios({
    url: '/main/getAutoDispatcher',
    method: 'post'
  })
}

//  值班操作子运单
export function dutyGetSubOrder (param) {
  return customAxios({
    url: '/main/duty/getSubOrder',
    method: 'post',
    data: param
  })
}

//  值班操作主运单
export function dutyGetMainOrder (param) {
  return customAxios({
    url: '/main/duty/getMainOrder',
    method: 'post',
    data: param
  })
}

//  值班操作主运单信息录入
export function dutyChangeMainOrder (param) {
  return customAxios({
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    url: '/main/duty/changeMainOrder',
    method: 'post',
    data: param
  })
}

//  值班操作子运单信息录入
export function dutyChangeSubOrder (param) {
  return customAxios({
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    url: '/main/duty/changeSubOrder',
    method: 'post',
    data: param
  })
}
